BookingDonationMy = function() {
	bookingDonationMyThis = this;
	bookingDonationMyThis.listCount = 1;
	//서버에 보내는 리스트 카운트
	bookingDonationMyThis.currPageNo = 1;
	//서버에 보내는 현재 페이지 번호
	bookingDonationMyThis.HTMLDom = null;
	//dom 으로 사용하는 클래스 변수
}
BookingDonationMy.prototype = {
	donationMyMainReservList : function() {
		var mj = new MJson();
		var cm = new ConnectionManager();

		mj.putPub(MJson.PUB.SID, "DR001");
		mj.putPub(MJson.PUB.SERVICENAME, "DonationMyMainReservList");

		mj.putPub(MJson.PUB.LISTCOUNT, bookingDonationMyThis.listCount);
		mj.putPub(MJson.PUB.CURRPAGENO, bookingDonationMyThis.currPageNo);
		mj.putClient(MJson.CLIENT.USERID, document.globalObj.LOGIN_DATA.userId);

		//console.log("request : " + mj.getJsonString());
		cm.requestGet(mj.getJsonString(), function(jsonData) {
			//console.log("성공 :: 통신");

			if (mj.checkServiceResult(jsonData)) {
				console.log("success :: " + JSON.stringify(jsonData));
				//console.log('donationMainReserveList :: 성공');
				if (jsonData.msp.contents.items != undefined) {
					//------- UI Display -------//

					var listLayer = bookingDonationMyThis._HTMLDom.list_layer;
					var listTitle = bookingDonationMyThis._HTMLDom.list_title;
					var listContentsLeft = bookingDonationMyThis._HTMLDom.list_contents_left;
					var lsitContentsRight = bookingDonationMyThis._HTMLDom.list_contents_right;
					listLayer.append(listTitle.clone());
					listLayer.append(listContentsLeft.clone());
					listLayer.append(lsitContentsRight.clone());
					var donationDateTime = listTitle.find('p:eq(0)');
					var donationTime = '<em>신청기간  :</em>' + jsonData.msp.contents.items.startDt + '~' + jsonData.msp.contents.items.endDt;
					donationDateTime.html(donationTime);

					var donationPublicDate = listTitle.find('p:eq(1)');
					var publicDate = (jsonData.msp.contents.items.publicDate ? jsonData.msp.contents.items.publicDate : jsonData.msp.contents.items.reservDate)
					var publicDate = '<em>당첨자발표  :</em>' + publicDate;
					donationPublicDate.html(publicDate);

					var donationTitle = list_contents_left.find('h5');
					var title = jsonData.msp.contents.items.courseInfoNm;
					donationTitle.html(title);

					var donationReserveDate = list_contents_left.find('li:eq(0)');
					reservDate = '<em>라운드날짜</em>' + jsonData.msp.contents.items.reservDate + '(' + jsonData.msp.contents.items.bookingDay + ')';
					donationReserveDate.html(reservDate);

					var donationTeaTime = list_contents_left.find('li:eq(1)');
					var teaTime = '<em>티타임</em>' + jsonData.msp.contents.items.bookingTime;
					donationTeaTime.html(teaTime);

					var donationGreenFee = list_contents_left.find('li:eq(2)');
					var greenFee = '<em>1인 그린피</em><mark>' + jsonData.msp.contents.items.donatePrice + '</mark>';
					donationGreenFee.html(greenFee);

					var donationApplyCnt = list_contents_right.find('p:eq(0)');
					var applyCnt = '참여 :<mark>' + jsonData.msp.contents.items.applyCnt + '</mark>명';
					donationApplyCnt.html(applyCnt);

					var doingText = list_contents_right.find('p:eq(1)');

					var date = new Date();
					var thisDay = date.getDate();
					var thisMonth = date.getMonth() + 1;
					var thisYear = date.getFullYear();

					var reservYear = new String(jsonData.msp.contents.items.reservDate).slice(0, 4);
					var reservMonth = new String(jsonData.msp.contents.items.reservDate).slice(5, 7);
					var reservDay = new String(jsonData.msp.contents.items.reservDate).slice(8, 10);
					if ((thisDay == reservDay) && (thisMonth == reservMonth) && (thisYear == reservYear)) {
						doingText.show();
					} else {
						doingText.hide();
					}

					list_contents_right.find('p:eq(2)').bind('click', function(event) {
						document.globalObj.DONATION_DATA.donation_seq = jsonData.msp.contents.items.reserveSeq;
						$.mobile.changePage('donation_view.html');
					});

					//--------------------------//

					bookingDonationMyThis.currPageNo++;
					//다음 데이터를 받기위해 페이지 넘버 1 더함
					bookingDonationMyThis.donationMainReserveList();
					//재귀함수 호출
				} else {
					if (bookingDonationMyThis.currPageNo == 1) {
						bookingDonationMyThis._HTMLDom.list_layer.append(bookingDonationMyThis._HTMLDom.list_noItem.clone());
						//내가 참여한 자선 예약이 없다는 의미의 dom객체
					}
					console.log("::::재귀함수 종료:::::");
					return;
				}
			} else {
				console.log('donationMainReserveList :: 실패');
			}
		}, function(e) {
			console.log("실패 :: 통신");
		});
	},
	onPageShow : function() {
		console.log(this);
		bookingDonationMyThis.listCount = 1;
		bookingDonationMyThis.currPageNo = 1;

		//-------DOM 객체 설정
		var list_layer = $('#donation_my_list');
		
		var list_noItem = list_layer.find('dl:eq(0)');
		var list_title = list_layer.find('dl:eq(1) > dt:first');
		var list_contents_left = list_layer.find('dd:first > div:eq(0)');
		var list_contents_right = list_layer.find('dd:first > div:eq(1)');

		bookingDonationMyThis._HTMLDom = {
			// 리스트 레이어
			"list_layer" : list_layer,
			"list_noItem" : list_noItem,
			"list_title" : list_title,
			"list_contents_left" : list_contents_left,
			"list_contents_right" : list_contents_right
		};
		list_layer.empty();
		//-------DOM 객체 설정
		bookingDonationMyThis.donationMyMainReservList();
		$("#goDonation").bind('click', function(event) {
			$.mobile.changePage('donation.html');
		});
	}
}